/* eslint-disable func-style */
import i18n from '@/components/i18n'

/**
 * Descripttion 验证
 * @version 1.0.0
 * @Author Bell
 * @ 使用
     引入 import V from '@/assets/scripts/validate'
     表单中使用如下
     <el-form :model="formData">
       <el-form-item label="汉字" prop="xxx" :rules="[V.required, V.chinese]">
         <FInput v-model.trim="formData.xxx" />
       </el-form-item>
     </el-form>
     表格表单中使用如下
     <el-form :model="formData">
       <el-table :data="formData.tableData">
         <el-table-column width="200" label="日期">
           <template slot-scope="scope">
             <el-form-item :prop="`tableData.${scope.$index}.xxx`" :rules="[V.required]" label=" " label-width="0">
               <FDatePicker width="100%" v-model="scope.row.xxx"/>
             </el-form-item>
           </template>
         </el-table-column>
       </el-table>
     </el-form>
 */
export default {
  required: { required: true, message: i18n.tc('validate.Can not be empty') }, // 非空
  username: { pattern: /^\w+$/, message: i18n.tc('validate.Please enter the correct user name') }, // 用户名
  password: { min: 6, max: 15, message: i18n.tc('validate.Please enter the correct password') }, // 密码
  number: { pattern: /^[0-9]*$/, message: i18n.tc('validate.Please enter a number') }, // 数字
  number2: { pattern: /^\d+\.?\d{0,2}$/, message: i18n.tc('validate.Please enter two decimal places') }, // 数字 小数点2位
  english: { pattern: /^[a-zA-Z]*$/, message: i18n.tc('validate.Please enter English') }, // 英文
  chineseAndEnglish: { pattern: /^[\u4e00-\u9fa5a-zA-Z]+$/, message: i18n.tc('validate.Please enter Chinese and English') } // 中文和英文
  // chinese: { validator: chinese, message: '请输入汉字' } // demo 新工程需删除
}

// demo 新工程需删除
/* function chinese(rule, value, callback) {
  if (!value) {
    callback();
    return;
  }
  const regexps = /^[\u4e00-\u9fa5]*$/;
  if (regexps.test(value)) {
    callback();
  } else {
    callback(new Error());
  }
} */
